<?php foreach ($books as $id => $book): ?>
    <book id="<?php echo $id ?>"<?php foreach ($book as $key => $value): ?> <?php echo $key ?>="<?php echo $value ?>"<?php endforeach; ?> />
<?php endforeach ?>